<template>
  <div class="GoodsDetails">
    <div class="tab">
      <div class="back">
        <van-icon name="arrow-left" />
      </div>
      <div class="menu">
        <span class="menu_item"> 商品 </span>
        <span class="menu_item"> 评价 </span>
        <span class="menu_item"> 详情 </span>
      </div>
      <div class="other"><van-icon name="ellipsis" /></div>
    </div>
    <div class="swiper">
      <van-swipe :autoplay="3000" :width="375" :height="375">
        <van-swipe-item v-for="(image, index) in Goodsimg" :key="index">
          <img v-lazy="image" />
        </van-swipe-item>
      </van-swipe>
    </div>
    <div class="pirce">
      <div class="price_left">
        <span
          >￥<span class="now">{{ Goods.price }}</span></span
        >
        <span class="before">￥{{ Goods.otPrice }}</span>
      </div>
      <div class="price_right">
        <i class="fa fa-clock-o"></i>
        <span>距结束</span>
        <Counttime :timeSwap="timeSwap"></Counttime>
      </div>
    </div>
    <div class="Title">
      <div class="tit_top">
        <h3 class="goods_title">{{ Goods.storeName }}</h3>
        <i class="share fa fa-share-square-o"></i>
      </div>
      <div class="tit_bot">
        <span>累计销售:{{ Goods.sales }}</span>
        <span class="number">限量</span>
      </div>
    </div>
    <div class="skeleton">
      <div class="top">
        已选择：
        <span>{{ goodsType[0] }}</span>
        <van-icon name="arrow" />
      </div>
      <div class="bot">
        <div class="imgs">
          <img
            v-for="item in imgs.slice(0, 4)"
            :key="item.id"
            :src="item.image"
            alt=""
          />
        </div>
        <div class="gray">共{{ imgs.length }}种规格可选</div>
      </div>
    </div>
    <div class="comment">
      <div class="usernumber">
        <div class="left">用户评价（{{ replay.total }}）</div>
        <div class="right">
          <span class="pink">{{ (replay.limit / replay.total) * 100 }}%</span>
          好评率<van-icon name="arrow" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
const Counttime = () => import("@/components/Littlecom/Counttime.vue");
export default {
  name: "GoodsDetails",
  components: { Counttime },
  data() {
    return {
      Goodsimg: [],
      timeSwap: 0,
      Goods: [],
      Goodsslect: [],
      goodsType: [],
      imgs: [],
      replay: [],
    };
  },
  async created() {
    this.timeSwap = this.$store.state.ScendSwap;
    const {
      data: { data },
    } = await this.$request(
      "get",
      `/fxh/seckill/detail/${this.$route.query.id}`
    );
    console.log(this.$route.query);
    this.Goods = data.storeSeckill;
    this.Goodsimg = JSON.parse(data.storeSeckill.sliderImage);
    this.Goodsslect = data.productValue;
    for (let key in this.Goodsslect) {
      this.goodsType.push(key);
      this.imgs.push(this.Goodsslect[key]);
    }

    const replay = await this.$request(
      "get",
      `/fxh/reply/list/${this.Goods.productId}`,
      {
        page: 1,
        limit: 3,
        type: 0,
      }
    );
    // console.log(replay.data.data);
    this.replay = replay.data.data;
  },
  mounted() {},

  methods: {},
};
</script>

<style lang="scss" scoped>
.GoodsDetails {
  position: relative;
  width: 375px;
  height: 87vh;
  .tab {
    z-index: 1000;
    @include between;
    box-sizing: border-box;
    align-items: center;
    width: 375px;
    height: 50px;
    position: fixed;
    top: 0;
    height: 50px;
    width: 100%;
    .back {
      color: #000;
      font-size: 16px;
      line-height: 29px;
      text-align: center;
      width: 29px;
      height: 29px;
      background: hsla(0, 0%, 100%, 0.3);
      border: 1px solid rgba(0, 0, 0, 0.1);
      border-radius: 50%;
      margin-left: 10px;
    }
    .menu {
      width: 230px;
      font-size: 15px;
      color: #050505;
      @include around;
    }

    .other {
      color: #000;
      font-size: 16px;
      line-height: 29px;
      text-align: center;
      width: 29px;
      height: 29px;
      background: hsla(0, 0%, 100%, 0.3);
      border: 1px solid rgba(0, 0, 0, 0.1);
      border-radius: 50%;
      margin-right: 10px;
    }
  }
  .swiper {
    img {
      width: 100%;
      height: 100%;
    }
  }
  .pirce {
    @include between;
    box-sizing: border-box;
    padding: 0 15px;
    align-items: center;
    width: 375px;
    height: 55px;
    background: #ff448f;
    .price_left {
      width: 156px;
      height: 30px;
      color: #fff;
      .now {
        color: #fff;
        font-weight: 700;
        font-size: 24px;
      }
      .before {
        margin-left: 5px;
        font-size: 13px;
        text-decoration: line-through;
      }
    }
    .price_right {
      @include around;
      align-items: center;
      color: white;
      .fa-clock-o {
        width: 15px;
        height: 16px;
        color: white;
      }
      span {
        font-size: 13px;
        margin-right: 10px;
      }
    }
  }
  .Title {
    padding-top: 15px;
    box-sizing: border-box;
    width: 345px;
    height: 94px;
    margin-top: 15px;
    border-radius: 5px;
    background: white;
    margin-left: 15px;
    .tit_top {
      margin: auto;
      @include between;
      width: 321px;
      height: 40px;
      .goods_title {
        width: 285px;
        height: 40px;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 16px;
        font-weight: 700;
      }
      .share {
        margin-top: 8px;
        font-size: 22px;
        color: #999;
      }
    }
    .tit_bot {
      @include between;
      box-sizing: border-box;
      width: 306px;
      margin-left: 10px;
      font-size: 11px;
      color: #82848f;
      margin-top: 15px;
      .number {
        margin-right: 125px;
      }
    }
  }
  .skeleton {
    margin-top: 20px;
    width: 345px;
    height: 89px;
    margin-left: 15px;
    border-radius: 5px;
    background: white;
    box-sizing: border-box;
    padding: 5px;
    .top {
      box-sizing: border-box;
      width: 300px;
      margin: auto;
      font-size: 13px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      color: #82848f;
      position: relative;
      span {
        font-size: 14px;
        color: #282828;
      }
      .van-icon {
        position: absolute;
        right: -3px;
        top: 3px;
      }
    }
    .bot {
      @include between;
      box-sizing: border-box;
      padding: 0 15px;
      width: 321px;
      height: 33px;
      margin-top: 20px;
      .imgs {
        padding-left: 33px;
        width: 160px;
        @include around;
        img {
          width: 33px;
          height: 33px;
          margin-right: 5px;
        }
      }
      .gray {
        width: 106px;
        height: 30px;
        flex: 1;
        line-height: 30px;
        box-sizing: border-box;
        background: #eeeeee;
        font-size: 13px;
        color: #82848f;
        text-align: center;
      }
    }
  }
  .comment {
    width: 345px;
    height: 111px;
    background: white;
    border-radius: 5px;
    margin-left: 15px;
    margin-top: 15px;
    .usernumber {
      @include between;
      align-items: center;
      box-sizing: border-box;
      padding: 0 20px;
      width: 345px;
      height: 43px;

      .left {
        font-size: 14px;
        color: #282828;
       
      }
      .right {
        font-size: 14px;
        color: grey;
         .pink{
          color: #ff448f !important;
        }
      }
    }
  }
}
</style>
